package com.qyer.search.model.aggregation;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Created by tangzheng on 16/7/17.
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Segment {

  @JsonProperty
  private String name;
  @JsonProperty
  private String type;
  @JsonProperty
  private int id;
  @JsonProperty
  private String ctype;

  public Segment(String name, String type, int id) {
    this.name = name;
    this.type = type;
    this.id = id;
  }

  public Segment(String name, String type, int id, String ctype) {
    this.name = name;
    this.type = type;
    this.id = id;
    this.ctype = ctype;
  }

  public String getCtype() {
    return ctype;
  }

  public void setCtype(String ctype) {
    this.ctype = ctype;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }

  @Override public boolean equals(Object o) {
    if (this == o)
      return true;
    if (o == null || getClass() != o.getClass())
      return false;

    Segment segment = (Segment) o;

    if (id != segment.id)
      return false;
    if (!name.equals(segment.name))
      return false;
    if (!type.equals(segment.type))
      return false;
    return ctype.equals(segment.ctype);

  }

  @Override public int hashCode() {
    int result = name.hashCode();
    result = 31 * result + type.hashCode();
    result = 31 * result + id;
    result = 31 * result + ctype.hashCode();
    return result;
  }

  @Override public String toString() {
    return "Segment{" +
      "name='" + name + '\'' +
      ", type='" + type + '\'' +
      ", id=" + id +
      ", ctype='" + ctype + '\'' +
      '}';
  }
}
